<template>
  <div>
    <div class="ele-page-header">
      <div class="ele-page-title">平台基础配置</div>
      <div class="ele-page-desc"> 用于前端平台相关信息配置。 </div>
    </div>
    <div class="ele-body"
         style="padding-bottom: 71px">
      <el-form ref="form"
               :model="form"
               :rules="rules"
               label-width="130px"
               @keyup.enter.native="submit"
               @submit.native.prevent>
        <el-card shadow="never"
                 header="基础配置"
                 body-style="padding: 22px 22px 0 22px;">
          <el-row :gutter="15">
            <!-- <el-col :lg="6"
                    :md="10">
              <el-form-item label="系统图标:"
                            prop="systemIcon">
                <span slot="label">
                  系统图标
                  <el-tooltip placement="top">
                    <div slot="content">
                      系统左侧LOGO展示<br />
                      大小尺寸为100px * 100px
                    </div>
                    <i class="el-icon-question" />
                  </el-tooltip>
                </span>

                <div class="ele-image-upload-list">
                  <div class="ele-image-upload-item ele-image-upload-button"
                       @click="modalPicTap('dan', 'sysLogo', '系统图标')">
                    <div>
                      <div tabindex="0"
                           class="el-upload el-upload--text">
                        <div class="el-upload-dragger">
                          <i class="el-icon-plus ele-image-upload-icon"></i>
                        </div>

                        <div class="ele-image-upload-item"
                             style="margin: 0 0 0 0"
                             v-if="form.sysLogo">
                          <div class="el-image">
                            <img :src="form.sysLogo"
                                 width="100%"
                                 height="100%"
                                 class="el-image__inner"
                                 style="object-fit: cover" />
                          </div>
                          <div class="ele-image-upload-close"
                               @click="handleRemove('systemIcon')"><i class="el-icon-close"></i></div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </el-form-item>
            </el-col> -->

            <el-col :xl="6"
                    :lg="12"
                    :md="24">
              <el-form-item label="积分名称:"
                            label-width="130px"
                            prop="integralName">
                <el-input v-model="form.integralName"
                          placeholder="请输入积分名称"
                          clearable></el-input>
              </el-form-item>
              <el-form-item label="签到积分:"
                            label-width="130px"
                            prop="checkInScore">
                <el-input v-model.number="form.checkInScore"
                          placeholder="请输入用户每天签到积分"
                          clearable></el-input>
              </el-form-item>
              <el-form-item label="积分价值:"
                            prop="integralValue">
                <el-input v-model="form.integralValue"
                          onkeyup="value=value.replace(/[^\-?\d.]/g,'')"
                          min="0"
                          type="number"
                          placeholder="一元等于 N个积分"
                          clearable>

                </el-input>

              </el-form-item>
              <el-form-item label="腾讯地图Key:"
                            label-width="130px"
                            prop="tencentMapKey">
                <el-input v-model="form.tencentMapKey"
                          placeholder="腾讯地图Key"
                          show-password
                          clearable></el-input>
                <!-- <span style="color: #909399">注意：【点击申请用于显示地理位置】</span> -->
              </el-form-item>
              <el-form-item label="附近范围(公里):"
                            prop="immediateRange">
                <el-input v-model="form.immediateRange"
                          onkeyup="value=value.replace(/[^\-?\d.]/g,'')"
                          placeholder="请输入附近范围(公里)"
                          clearable><template slot="append">公里</template></el-input>

              </el-form-item>

              <el-form-item label="技师保证金:"
                            prop="securityDeposit">
                <el-input v-model="form.securityDeposit"
                          placeholder="请输入保证金"
                          onkeyup="value=value.replace(/[^\-?\d.]/g,'')"
                          clearable><template slot="append">元</template></el-input>
              </el-form-item>
              <el-form-item label="订单抽佣比例:"
                            prop="securityDeposit">
                <el-input v-model="form.platformServiceCharge"
                          min="0"
                          max="100"
                          type="number"
                          placeholder="请输入订单抽佣比例"
                          clearable>
                  <template slot="append">%</template>
                </el-input>
              </el-form-item>

              <el-form-item label="加钟抽佣比例:"
                            prop="securityDeposit">
                <el-input v-model.number="form.addBellServiceCharge"
                          min="0"
                          max="100"
                          type="number"
                          placeholder="请输入加钟抽佣比例"
                          clearable>
                  <template slot="append">%</template>
                </el-input>
              </el-form-item>
              <el-form-item label="退款手续费:"
                            prop="securityDeposit">
                <el-input v-model.number="form.refundServiceCharge"
                          min="0"
                          max="100"
                          type="number"
                          placeholder="请输入退款手续费"
                          clearable>
                  <template slot="append">%</template>
                </el-input>
              </el-form-item>
              <el-form-item label="联系管理员电话:"
                            prop="emergencyContactAdmin">
                <el-input v-model.number="form.emergencyContactAdmin"
                          maxlength="11"
                          placeholder="请填写紧急救援联系管理员电话"
                          clearable></el-input>
              </el-form-item>
              <el-form-item label="小程序原始ID:"
                            prop="primitiveId">
                <el-input v-model="form.primitiveId"
                          placeholder="请填写小程序原始ID"
                          clearable></el-input>
              </el-form-item>

              <el-form-item label="服务项目过审开关:"
                            prop="serviceItemHiding">
                <el-tooltip :content="form.serviceItemHiding=='1'?'隐藏服务项目':'显示服务项目'"
                            placement="top">
                  <el-switch active-value='2'
                             inactive-value='1'
                             v-model="form.serviceItemHiding">
                  </el-switch>
                </el-tooltip>
                <div class="prompt">用于小程序的服务项目审核</div>

              </el-form-item>
              <el-form-item label="分类开关:"
                            prop="classifySwitch">

                <el-radio-group v-model="form.classifySwitch"
                                size="small">
                  <el-radio :label="1">开启</el-radio>
                  <el-radio :label="2">关闭</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="退款方式:"
                            prop="refundMethod">
                <el-radio-group v-model="form.refundMethod"
                                size="small">
                  <el-radio label="0"
                            value="0">自动退款</el-radio>
                  <el-radio value="1"
                            label="1">人工退款</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="关注公众号:"
                            prop="followThePublicAccount">
                <!--<ele-image-upload v-model="form.serviceQrCode" :limit="1" :drag="true" :multiple="false"  @upload="onUpload" />-->
                <div class="ele-image-upload-list">
                  <div class="ele-image-upload-item ele-image-upload-button"
                       @click="modalPicTap('dan', 'followThePublicAccount', '关注公众号')">
                    <div>
                      <div tabindex="0"
                           class="el-upload el-upload--text">
                        <div class="el-upload-dragger">
                          <i class="el-icon-plus ele-image-upload-icon"></i>
                        </div>

                        <div class="ele-image-upload-item"
                             style="margin: 0 0 0 0"
                             v-if="form.followThePublicAccount">
                          <div class="el-image">
                            <img :src="form.followThePublicAccount"
                                 width="100%"
                                 height="100%"
                                 class="el-image__inner"
                                 style="object-fit: cover" />
                          </div>
                          <div class="ele-image-upload-close"
                               @click="handleRemove('followThePublicAccount')"><i class="el-icon-close"></i></div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </el-form-item>

            </el-col>
            <el-col :xl="8"
                    :lg="12"
                    :md="24">
              <el-form-item label="充值说明:"
                            prop="systemIcon">
                <span slot="label">
                  充值说明:
                  <el-tooltip placement="top">
                    <div slot="content"> 充值说明<br /> </div>
                    <i class="el-icon-question" />
                  </el-tooltip>
                </span>
                <tinymce-editor v-model="form.topUpInstructions"
                                :init="{ height: 350 }" />
              </el-form-item>
            </el-col>
            <el-col :xl="8"
                    :lg="12"
                    :md="24">
              <el-form-item label="服务说明:"
                            prop="systemIcon">
                <span slot="label">
                  服务说明:
                  <el-tooltip placement="top">
                    <div slot="content"> 服务说明<br /> </div>
                    <i class="el-icon-question" />
                  </el-tooltip>
                </span>
                <tinymce-editor v-model="form.serviceDeclaration"
                                :init="{ height: 350 }" />
              </el-form-item>
            </el-col>
            <el-col :xl="8"
                    :lg="12"
                    :md="24">
              <el-form-item label="弹窗提示:"
                            prop="systemIcon">
                <span slot="label">
                  弹窗提示:
                  <el-tooltip placement="top">
                    <div slot="content"> 客户下单告知相关违法行为<br /> </div>
                    <i class="el-icon-question" />
                  </el-tooltip>
                </span>
                <tinymce-editor v-model="form.popupPrompt"
                                :init="{ height: 350 }" />
              </el-form-item>
            </el-col>

          </el-row>
        </el-card>
        <!-- <el-row :gutter="15">
          <el-col :lg="12"
                  :md="12">
            <el-card shadow="never"
                     header="小程序配置"
                     body-style="padding: 22px 22px 0 22px;">
              <el-row :gutter="15">
                <el-col :lg="24"
                        :md="24">
                <el-form-item label="appid:"
                                prop="xcxAppid">
                    <el-input v-model="form.xcxAppid"
                              placeholder="请输入小程序appid"
                              clearable></el-input>
                  </el-form-item>
                  <el-form-item label="appSecret:"
                                prop="loginBackground">
                    <el-input v-model="form.xcxAppsecret"
                              show-password
                              placeholder="请输入小程序appSecret"
                              clearable></el-input>
                  </el-form-item> 

                </el-col>
              </el-row>
            </el-card>
          </el-col>
          <el-col :lg="12"
                  :md="12">
            <el-card shadow="never"
                     header="公众号配置"
                     body-style="padding: 22px 22px 0 22px;">
              <el-row :gutter="15">
                <el-col :lg="24"
                        :md="24">
                 <el-form-item label="appid:"
                                prop="loginBackground">
                    <el-input v-model="form.gzhAppid"
                              placeholder="请输入公众号appid"
                              clearable></el-input>
                  </el-form-item>
                  <el-form-item label="openid:"
                                prop="adminOpenId">
                    <el-input v-model="form.adminOpenId"
                              placeholder="请输入管理员公众号openid"
                              clearable></el-input>
                  </el-form-item> -->
        <!-- <el-form-item label="appsecret:"
                                prop="loginBackground">
                    <el-input v-model="form.gzhAppsecret"
                              show-password
                              placeholder="请输入公众号appSecret"
                              clearable></el-input>
                  </el-form-item>
        </el-col>
        </el-row>
        </el-card>
        </el-col>
        </el-row> -->
        <el-card shadow="never"
                 header="分享图片"
                 body-style="padding: 22px 22px 0 22px;">
          <el-row :gutter="15">
            <el-col :lg="10"
                    :md="8">
              <el-form-item label="分享图片:"
                            prop="sharePictures">
                <!--<ele-image-upload v-model="form.serviceQrCode" :limit="1" :drag="true" :multiple="false"  @upload="onUpload" />-->
                <div class="ele-image-upload-list">
                  <div class="ele-image-upload-item ele-image-upload-button"
                       @click="modalPicTap('dan', 'sharePictures', '分享图片')">
                    <div>
                      <div tabindex="0"
                           class="el-upload el-upload--text">
                        <div class="el-upload-dragger">
                          <i class="el-icon-plus ele-image-upload-icon"></i>
                        </div>

                        <div class="ele-image-upload-item"
                             style="margin: 0 0 0 0"
                             v-if="form.sharePictures">
                          <div class="el-image">
                            <img :src="form.sharePictures"
                                 width="100%"
                                 height="100%"
                                 class="el-image__inner"
                                 style="object-fit: cover" />
                          </div>
                          <div class="ele-image-upload-close"
                               @click="handleRemove('sharePictures')"><i class="el-icon-close"></i></div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </el-form-item>
            </el-col>
            <el-col :lg="10"
                    :md="8">
              <el-form-item label="分享标题"
                            prop="shareTitle">
                <el-input maxlength="11"
                          v-model="form.shareTitle"
                          placeholder="请输入分享标题"
                          clearable />
              </el-form-item>
            </el-col>
            <el-col :lg="10"
                    :md="8">
              <el-form-item label="分享描述"
                            prop="shareDescribe">
                <el-input v-model="form.shareDescribe"
                          placeholder="请输入分享描述"
                          clearable />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <el-card shadow="never"
                 header="出行费用"
                 body-style="padding: 22px 22px 0 22px;">
          <el-row :gutter="15">
            <el-col :span="24">

              <el-form-item label="出行选择:"
                            prop="travelExpenseType">
                <el-radio-group v-model="form.travelExpenseType">
                  <el-radio value="1"
                            label="1">无费用</el-radio>
                  <el-radio value="2"
                            label="2">固定费用</el-radio>
                  <el-radio label="3"
                            value="3">公里计算</el-radio>
                </el-radio-group>
              </el-form-item>

              <el-row :gutter="15">
                <el-col :span="15">
                  <el-form-item v-if="form.travelExpenseType == '2'"
                                label="起步价格:"
                                prop="startingPrice">
                    <el-input v-model="form.startingPrice"
                              min="0"
                              type="number"
                              placeholder="请输入技师起步价格"
                              clearable><template slot="prepend">计费</template><template slot="append">元</template></el-input>
                    <span class="prompt">选择固定费用后，用户下单不管距离是否远近，技师出行费用固定不变</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="15">
                <el-col :span="15">
                  <div>
                    <el-form-item v-if="form.travelExpenseType == '3'"
                                  label="出行费用:"
                                  prop="travelExpense">
                      <el-input v-model="form.startingKilometre"
                                onkeyup="value=value.replace(/[^\-?\d.]/g,'')"
                                placeholder="请输入公里数"
                                clearable><template slot="prepend">起步</template><template slot="append">公里内</template></el-input>

                      <el-input style="margin-top: 15px"
                                onkeyup="value=value.replace(/[^\-?\d.]/g,'')"
                                v-model="form.startingPrice"
                                placeholder="请输入出行费用"
                                clearable><template slot="prepend">计费</template><template slot="append">元</template></el-input>
                    </el-form-item>
                    <el-form-item v-if="form.travelExpenseType == '3'"
                                  label="超出公里费用:"
                                  prop="exceedExpense">
                      <el-input v-model="form.exceedExpense"
                                onkeyup="value=value.replace(/[^\-?\d.]/g,'')"
                                placeholder="请输入超出公里费用"
                                clearable><template slot="prepend">每公里计费</template><template slot="append">元</template></el-input>
                    </el-form-item>
                  </div>
                </el-col>
              </el-row>
              <!--校检表单-->
              <!-- <div v-if="form.travelExpenseType!='1'&&form.travelExpenseType!='2'">
                <div v-for="(item, index) in textList"
                     :key="index">
                  <el-form-item :label="'超出公里费用'"
                                class="form-item-padding">
                    <div style="display:flex;">
                      <el-input :rows="2"
                                v-model="item.minimumKilometers"
                                placeholder="请输入最小公里"
                                class="e-input" />
                      -
                      <el-input :rows="2"
                                v-model="item.maximumKilometers"
                                placeholder="请输入最大公里"
                                class="e-input" />
                      =
                      <el-input :rows="2"
                                v-model="item.money"
                                placeholder="请输入金额"
                                class="e-input" />
                      <el-button class="btn-position"
                                 @click="add"
                                 v-if="0==index">+</el-button>
                      <el-button class="btn-position"
                                 @click="subtract(index)"
                                 v-else>-</el-button>
                    </div>
                  </el-form-item>
                </div>
              </div> -->
              <el-form-item label="技师入驻协议:"
                            prop="travelExpense">
                <tinymce-editor ref="editorRef"
                                v-model="form.agreement" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <!--上传图片组件-->
        <uploadPictures ref="upload"
                        :isChoice="isChoice"
                        :visible.sync="modalPic"
                        @getPic="getPic"
                        :gridBtn="gridBtn"
                        :gridPic="gridPic"
                        :title="modalTitle"></uploadPictures>

        <!--
        <uploadPictures ref="upload"
                        :isChoice="isChoice"
                        :visible.sync="modalPic"
                        @getPic="getPic"
                        :gridBtn="gridBtn"
                        :gridPic="gridPic"
                        :title="modalTitle"></uploadPictures> -->

        <!-- 底部工具栏 -->
        <div class="ele-bottom-tool">
          <div v-if="validMsg"
               class="ele-text-danger">
            <i class="el-icon-circle-close"></i>
            <span>{{ validMsg }}</span>
          </div>
          <div class="ele-bottom-tool-actions">
            <el-button type="primary"
                       :loading="loading"
                       @click="submit">
              提交
            </el-button>
          </div>
        </div>
      </el-form>
    </div>
  </div>
</template>
<script>
import TinymceEditor from '@/components/TinymceEditor/index.vue';
import {
  sitePlatformConfigModify,
  sitePlatformConfigDetail,
  sitePlatformConfigAdd
} from '@/api/basicConfiguration/platformConfiguration';
import uploadPictures from './components/uploadImg';
// import { save, query } from '@/api/agent/pointAllocation';
const DEFAULT_FORM = {
  // oemId: this.$store.state.user.info.oemId,
  // systemIcon: [],
  // site_name:'',
  // browserIcon:[],
  // site_copyright:'',
  // site_beian:'',
  // site_jingbeian:'',
  // loginBackground: [],
  // loginLeftIcon:[],
  // kf_date:'',
  // serviceQrCode:[],
  // kf_mailbox:'',
  // kf_phone:'',
  // kf_address:'',
};
import EleImageUpload from 'ele-admin/es/ele-image-upload';
import request from '@/utils/request';
export default {
  name: 'FormAdvanced',
  components: { uploadPictures, TinymceEditor },
  data () {
    return {
      // 最大公里数
      maximumKilometers: '',
      // 最小公里数
      minimumKilometers: '',
      //   金额
      money: '',
      pricePerKilometerArr: [],
      // 列表
      textList: [{ minimumKilometers: '', maximumKilometers: '', money: '' }],
      // 复选框
      checkList: ['D音H5任务发布'],
      // 能力名称——能力选择——复选框
      checkSelList: [],
      modalTitle: '',
      modalPic: false,
      isChoice: '单选',
      gridBtn: {
        xl: 4,
        lg: 8,
        md: 8,
        sm: 8,
        xs: 8
      },
      gridPic: {
        xl: 6,
        lg: 8,
        md: 12,
        sm: 12,
        xs: 12
      },
      // 表单提交状态
      loading: false,
      // 表单数据
      form: {
        // 系统图标
        sysLogo: '',
        // 积分名字
        integralName: '',
        // 腾讯地图key
        tencentMapKey: '',
        // 小程序appid
        // xcxAppid: '',
        // 小程序appsecret
        // xcxAppsecret: '',
        // 用户签到积分
        checkInScore: 0,
        // 加钟手续费
        addBellServiceCharge: '',
        refundMethod: '0',
        // 公众号appid
        // gzhAppid: '',
        // 公众号appsecret
        // gzhAppsecret: '',
        // 分享图片
        sharePictures: '',
        // 小程序原始ID
        primitiveId: '',
        serviceItemHiding: '',
        // 分享标题
        shareTitle: '',
        // 公里
        immediateRange: '',
        // 保证金
        securityDeposit: '',
        // 出行费用类型
        travelExpenseType: '1',
        // 出行费用
        travelExpense: '',
        // 起步价
        startingPrice: '',
        // 起步公里
        startingKilometre: '',
        // 超出每公里费用
        exceedExpense: '',
        //每公里价格
        // pricePerKilometer: '',
        // 入驻协议
        agreement: '',
        // 站点id
        siteId: this.$store.state.site.info.id,
        // 充值说明
        topUpInstructions: '',
        // 管理员公众号openid
        // adminOpenId: '',
        // 服务说明
        serviceDeclaration: '',
        // 平台手续费
        platformServiceCharge: '',
        // 紧急联系管理员
        emergencyContactAdmin: '',
        // 分享描述
        shareDescribe: '',
        // 积分价值
        integralValue: '',
        followThePublicAccount: '',
        // 退款手续费
        refundServiceCharge: '',
        // 分类开关
        classifySwitch: 1,
        // 弹框提示
        popupPrompt: '',
      },
      isUpdata: false,
      // 表单验证规则
      rules: {
        name: [
          {
            required: true,
            message: '请输入仓库名',
            trigger: 'blur'
          }
        ],
        url: [
          {
            required: true,
            message: '请输入仓库域名',
            trigger: 'blur'
          }
        ],
        datetime: [
          {
            required: true,
            message: '请选择生效日期',
            trigger: 'blur'
          }
        ],
        administrator: [
          {
            required: true,
            message: '请选择仓库管理员',
            trigger: 'blur'
          }
        ],
        approver: [
          {
            required: true,
            message: '请选择审批人',
            trigger: 'blur'
          }
        ],
        type: [
          {
            required: true,
            message: '请选择仓库类型',
            trigger: 'blur'
          }
        ],
        task: [
          {
            required: true,
            message: '请输入任务名',
            trigger: 'blur'
          }
        ],
        description: [
          {
            required: true,
            message: '请输入任务表述',
            trigger: 'blur'
          }
        ],
        executor: [
          {
            required: true,
            message: '请选择执行人',
            trigger: 'blur'
          }
        ],
        officer: [
          {
            required: true,
            message: '请选择责任人',
            trigger: 'blur'
          }
        ],
        reminder: [
          {
            required: true,
            message: '请选择提醒时间',
            trigger: 'blur'
          }
        ],
        taskType: [
          {
            required: true,
            message: '请选择任务类型',
            trigger: 'blur'
          }
        ]
      },
      // 表单验证信息
      validMsg: '',
      checkAll: [],
      checkSelAll: []
    };
  },
  mounted () {
    this.querys();
  },
  methods: {
    querys () {
      // 查询回显
      sitePlatformConfigDetail({
        siteId: this.form.siteId
      })
        .then((msg) => {
          console.log(msg);
          if (msg) {
            //   是修改
            this.$util.assignObject(this.form, {
              ...msg
            });
            this.form.id = msg.id;
            this.isUpdata = true;

            //  调用出行获取每公里的价格
            //   this.pricePerKilometer(msg.pricePerKilometer)
          } else {
            // 修改
            this.isUpdata = false;
          }
        })
        .catch((e) => {
          this.$message.error(e.message);
        });
    },

    // pricePerKilometer (value) {
    //   const result = value.split(',')
    //   this.pricePerKilometerArr = []
    //   result.forEach(str => {
    //     const arr = str.split("-");  // 按照破折号进行分割
    //     const obj = {
    //       maximumKilometers: parseInt(arr[0]),  // 将第一个分割结果转换成数值类型并赋值给 minimumKilometers
    //       minimumKilometers: parseInt(arr[1]),  // 将第二个分割结果转换成数值类型并赋值给 maximumKilometers
    //       money: parseInt(arr[2])  // 将第三个分割结果转换成数值类型并赋值给 money
    //     };
    //     this.pricePerKilometerArr.push(obj)
    //     this.textList = this.pricePerKilometerArr
    //   });

    //   console.log(this.pricePerKilometerArr)
    // },
    checkClick (e) {
      console.log('e=====', e);
      this.checkAll = e;
    },
    checkSelClick (e) {
      console.log('e=====', e);
      this.checkSelAll = e;
    },
    // 选择图片
    modalPicTap (tit, picTit, openTitle) {
      this.modalTitle = openTitle;
      this.isChoice = tit === 'dan' ? '单选' : '多选';
      this.picTit = picTit;
      this.modalPic = true;
      this.$nextTick(() => {
        this.$refs['upload'].show();
      });
    },
    // 选中图片
    getPic (pc) {
      console.log('pc========', pc);
      switch (this.picTit) {
        case 'sysLogo':
          this.form.sysLogo = pc.imgUrl;
          break;

        case 'sharePictures':
          this.form.sharePictures = pc.imgUrl;
          break;
        case 'followThePublicAccount':
          this.form.followThePublicAccount = pc.imgUrl;
          break;
      }
      this.modalPic = false;
    },
    //删除图片
    handleRemove (field) {
      this.form[field] = '';
    },
    //  加
    add () {
      let startingPrice = {
        minimumKilometers: '',
        maximumKilometers: '',
        money: ''
      };
      this.textList.push(startingPrice);
      console.log('this.form.textList', this.textList, this.textList.length);
      //
    },

    //减
    subtract (index) {
      this.textList.splice(index, 1);
      console.log('this.form.textList', this.textList, this.textList.length);
    },
    /* 表单提交 */
    submit () {
      this.$refs['form'].validate((valid, obj) => {
        if (valid) {
          //   this.pricePerKilometerArr = []
          //   if (this.form.travelExpenseType == 3) {
          //     console.log(this.textList)
          //     this.textList.forEach((item) => {
          //       this.pricePerKilometerArr.push(`${item.maximumKilometers}-${item.minimumKilometers}-${item.money}`)
          //     })
          //     this.form.pricePerKilometer = this.pricePerKilometerArr.join(',');

          //   }
          // 手机号验证
          if (
            this.form.phone &&
            this.$sun.checkModbile(this.form.phone) == false
          ) {
            this.$message.error('手机号码格式不正确！');
            return;
          }
          // 邮箱验证
          if (
            this.form.email &&
            this.$sun.checkEmail(this.form.email + '.com') == false
          ) {
            this.$message.error('邮箱格式不正确！');
            return;
          }

          this.validMsg = '';
          this.loading = true;

          const data = {
            ...this.form
          };
          console.log(data);
          const saveOrUpdate = this.isUpdata
            ? sitePlatformConfigModify
            : sitePlatformConfigAdd;
          saveOrUpdate(data)
            .then((msg) => {
              this.loading = false;
              // id 不存在则调用查询是否已保存，否则保存多次都会不传id
              // if(!this.form.id){
              this.querys();
              // }
              this.$message.success('提交成功！');
            })
            .catch((e) => {
              this.loading = false;
              this.$message.error(e.message);
            });
        } else {
          this.validMsg = ` 共有校验 ${Object.keys(obj).length} 项不通过`;
          return false;
        }
      });
    },
    onUpload (item) {
      console.log('item:', item);
      item.status = 'uploading';
      const formData = new FormData();
      formData.append('file', item.file);
      request({
        url: '/common/uploadFile',
        method: 'post',
        data: formData,
        onUploadProgress: (e) => {
          // 文件上传进度回调
          if (e.lengthComputable) {
            item.progress = (e.loaded / e.total) * 100;
          }
        }
      })
        .then((res) => {
          if (res.data.code === 0) {
            item.status = 'done';
            item.url = res.data.data.url;
            // 如果你上传的不是图片格式, 建议将 url 字段作为缩略图, 再添加其它字段作为最后提交数据
            //item.url = res.data.data.thumbnail;  // 也可以不赋值 url 字段, 默认会显示为一个文件图标
            item.fileUrl = res.data.data.url;
          }
        })
        .catch((e) => {
          item.status = 'exception';
        });
    }
  }
};
</script>
<style>
.prompt {
  color: rgb(185, 188, 190);
}
</style>
